package edu.hawaii.myisern.action;

import java.io.IOException;
import java.net.MalformedURLException;
import junit.framework.TestCase;

import org.junit.Ignore;
import org.junit.Test;
import org.xml.sax.SAXException;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebResponse;

/**
 * Tests the addOrganization ActionBean
 * 
 * @author Sonwright M. Gomez
 * 
 */
public class TestAddOrganizationActionBean extends TestCase {
  /** Get the test host. */
  private String testHost = System.getProperty("test.host");

  /**
   * Tests the AddOrganization Actionbean.
   * 
   * @throws SAXException if error occurs with xml parser.
   * @throws MalformedURLException if error occurs with URL.
   * @throws IOException if error occurs with IO.
   */
  @Ignore @Test
  public void testAddCollaboration() throws SAXException, MalformedURLException, IOException {
    WebConversation conversation = new WebConversation();

    String pageTitle = "Welcome to ISERN";

    String Url = testHost + "myisern-onyx/addOrganization.jsp";
    WebResponse response = conversation.getResponse(Url);
    assertEquals("Checking addCollaboration.jsp retrieval", pageTitle, response.getTitle());
    
    AddOrganizationActionBean ao = new AddOrganizationActionBean();
    ao.setErrorMessage("ERROR");
    ao.setOrganizationAffiliatedResearchers("oar");
    ao.setOrganizationContact("contact");
    ao.setOrganizationCountry("country");
    ao.setOrganizationName("name");
    ao.setOrganizationResearchDescription("description");
    ao.setOrganizationResearchKeywords("keywords");
    ao.setOrganizationType("type");
    ao.setOrganizationUrl("url");
    assertSame("ERROR same","ERROR", ao.getErrorMessage());
    assertSame("oar same", "oar", ao.getOrganizationAffiliatedResearchers());
    assertSame("contact same", "contact", ao.getOrganizationContact());
    assertSame("country same", "country", ao.getOrganizationCountry());
    assertSame("name same", "name", ao.getOrganizationName());
    assertSame("desc same", "description", ao.getOrganizationResearchDescription());
    assertSame("keywords same", "keywords", ao.getOrganizationResearchKeywords());
    assertSame("type same", "type", ao.getOrganizationType());
    assertSame("url same", "url", ao.getOrganizationUrl());
  }
}
